// 题目接口
import {request} from '../utils/request'

const questionApi = {
  questionSearch: '/question/search',
  questionsSearchByBank: '/questionBank/search',
  findSubjectsByHouse: '/subject/findSubjectsByHouse',
  getKnowledgePoints: '/subject/getKnowledgePoints',
  queryById: '/question/queryById',
  findSubjectByName: '/subject/findSubjectByName',
  addQuestion: '/questionBank/addQuestion'
}

// 查找该学院所有题目
export function questionSearchAll (parameter) {
  return request({
    url: questionApi.questionSearch,
    method: 'get',
    params: {
      page_size: parameter.page_size,
      index: parameter.index,
      house: parameter.house
    }
  })
}

// 条件查询
export function questionSearch (parameter) {
  return request({
    url: questionApi.questionSearch,
    method: 'get',
    params: {
      page_size: parameter.page_size,
      index: parameter.index,
      house: parameter.house,
      subjectId: parameter.subjectId,
      knowledgePointId: parameter.knowledgePointId,
      questionType: parameter.questionType,
      isExamQuestion: parameter.examQuestion
    }
  })
}

// 查找该科目该题型所有考试
export function questionSearchAdd (parameter) {
  return request({
    url: questionApi.questionSearch,
    method: 'get',
    params: {
      page_size: parameter.page_size,
      index: parameter.index,
      subjectId: parameter.subjectId,
      questionType: parameter.questionType,
      isExamQuestion: parameter.examQuestion
    }
  })
}

// 查找题库内所有题目
export function questionsSearchByBank (parameter) {
  return request({
    url: questionApi.questionsSearchByBank,
    method: 'get',
    params: {
      page_size: parameter.page_size,
      index: parameter.index,
      questionBankId: parameter.questionBankId,
      knowledgePointId: parameter.knowledgePointId,
      questionType: parameter.questionType
    }
  })
}

// 查找该学院所有科目
export function findSubjectsByHouse (house) {
  return request({
    url: questionApi.findSubjectsByHouse,
    method: 'get',
    params: {
      house: house
    }
  })
}

// 查找该科目所有知识点
export function getKnowledgePoints (subjectId) {
  return request({
    url: questionApi.getKnowledgePoints,
    method: 'get',
    params: {
      subjectId: subjectId
    }
  })
}

// 根据id获取题目
export function queryById (questionId) {
  return request({
    url: questionApi.queryById,
    method: 'get',
    params: {
      questionId: questionId
    }
  })
}

export function findSubjectByName (name) {
  return request({
    url: questionApi.findSubjectByName,
    method: 'get',
    params: {
      name: name
    }
  })
}

// 添加题目至题库
export function addQuestionToBank (info) {
  return request({
    url: questionApi.addQuestion,
    method: 'post',
    params: {
      bankId: info.bankId,
      questionId: info.questionId
    }
  })
}
